class Solution {
public:
    vector<int> getRow(int rowIndex) {
        std::vector<int> dp(rowIndex+1,1);

        for(int i = 1; i < rowIndex+1; i++)
        {
            int pre1 = dp[1];
            int pre2 = dp[0];

            for(int j = 1; j < i; j++)
            {
                dp[j] = pre1 + pre2;
                pre2 = pre1;
                pre1 = dp[j+1];
            }
        }

        return dp;
    }

};